# Copyright 20126 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

include config.mk
include $(CFG_SRC_DIR)mk/util.mk

ifdef VERBOSE
BOOTSTRAP_ARGS := -v
else
BOOTSTRAP_ARGS :=
endif

BOOTSTRAP := $(CFG_PYTHON) $(CFG_SRC_DIR)src/bootstrap/bootstrap.py

all:
	$(Q)$(BOOTSTRAP) build $(BOOTSTRAP_ARGS)
	$(Q)$(BOOTSTRAP) doc $(BOOTSTRAP_ARGS)

# Don’t use $(Q) here, always show how to invoke the bootstrap script directly
help:
	$(BOOTSTRAP) --help

clean:
	$(Q)$(BOOTSTRAP) clean $(BOOTSTRAP_ARGS)

rustc-stage1:
	$(Q)$(BOOTSTRAP) build --stage 1 src/libtest $(BOOTSTRAP_ARGS)
rustc-stage2:
	$(Q)$(BOOTSTRAP) build --stage 2 src/libtest $(BOOTSTRAP_ARGS)

docs: doc
doc:
	$(Q)$(BOOTSTRAP) doc $(BOOTSTRAP_ARGS)
nomicon:
	$(Q)$(BOOTSTRAP) doc src/doc/nomicon $(BOOTSTRAP_ARGS)
book:
	$(Q)$(BOOTSTRAP) doc src/doc/book $(BOOTSTRAP_ARGS)
standalone-docs:
	$(Q)$(BOOTSTRAP) doc src/doc $(BOOTSTRAP_ARGS)
check:
	$(Q)$(BOOTSTRAP) test $(BOOTSTRAP_ARGS)
check-cargotest:
	$(Q)$(BOOTSTRAP) test src/tools/cargotest $(BOOTSTRAP_ARGS)
dist:
	$(Q)$(BOOTSTRAP) dist $(BOOTSTRAP_ARGS)
install:
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
	$(Q)echo "'sudo make install' is not supported currently."
else
	$(Q)$(BOOTSTRAP) dist --install $(BOOTSTRAP_ARGS)
endif
tidy:
	$(Q)$(BOOTSTRAP) test src/tools/tidy $(BOOTSTRAP_ARGS) --stage 0

check-stage2-android:
	$(Q)$(BOOTSTRAP) --step check-target --target arm-linux-androideabi

.PHONY: dist
